package com.xq.shop.controller;


import com.xq.shop.dto.IntegerDto;
import com.xq.shop.service.IOrderTrendsService;
import com.xq.shop.service.IUserService;
import com.xq.shop.vo.OrderTrendsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import utils.BaseResult;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 * 订单动态表 前端控制器
 * </p>
 *
 * @author gaoxiaojin
 * @since 2024-07-30
 */
@RestController
@RequestMapping("/order/trends")
public class OrderTrendsController {

    private final IOrderTrendsService orderTrendsService;
    private final IUserService userService;

    @Autowired
    public OrderTrendsController(IOrderTrendsService orderTrendsService, IUserService userService) {
        this.orderTrendsService = orderTrendsService;
        this.userService = userService;
    }

    @RequestMapping("/queryTrendByOrderId")
    public BaseResult<List<OrderTrendsVo>> queryTrendByOrderId(@RequestBody @Validated IntegerDto dto, HttpServletRequest request) {
        userService.getInfo(request);
        BaseResult<List<OrderTrendsVo>> result = new BaseResult<>();
        List<OrderTrendsVo> page = orderTrendsService.queryTrendByOrderId(dto);
        result.initializeSuccess(page);
        return result;
    }
}
